import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;

class MyComponent extends JPanel {
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        // 绘制一个矩形
        g.drawRect(50, 50, 100, 100);
        // 绘制一个字符串
        g.drawString("Hello, World!", 200, 100);
    }
}

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame("My Component Example");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
        
        MyComponent component = new MyComponent();
        frame.add(component);
        
        frame.setVisible(true);
    }
}